package org.liveboardgames.agricola.vo.farm
{
	import org.liveboardgames.agricola.model.enums.AbstractEnum;
	import org.liveboardgames.agricola.model.enums.HouseTypeEnum;
	import org.liveboardgames.agricola.view.component.ImageHandler;

	[Bindable]
	public class FarmElement
	{
		public static const WOODEN_ROOM:String = "WOODEN_ROOM";

		public static const CLAY_ROOM:String = "CLAY_ROOM";

		public static const STONE_ROOM:String = "STONE_ROOM";

		public static const FIELD:String = "FIELD";

		public static const STABLE:String = "STABLE";

		public static function isRoom(farmElement:String):Boolean
		{
			return (farmElement == WOODEN_ROOM || farmElement == CLAY_ROOM || farmElement == STONE_ROOM);
		}

		public static function getRoomFromMaterial(material:String):String
		{
			var result:String;

			if (material == HouseTypeEnum.WOODEN)
			{
				result = WOODEN_ROOM;
			}
			else if (material == HouseTypeEnum.CLAY)
			{
				result = CLAY_ROOM;
			}
			else if (material == HouseTypeEnum.STONE)
			{
				result = STONE_ROOM;
			}

			return result;
		}

		public static function getRoomMaterial(room:String):String
		{
			var result:String = null;

			if (room == WOODEN_ROOM)
			{
				result = HouseTypeEnum.WOODEN;
			}
			else if (room == CLAY_ROOM)
			{
				result = HouseTypeEnum.CLAY;
			}
			else if (room == STONE_ROOM)
			{
				result = HouseTypeEnum.STONE;
			}

			return result;
		}

		public static function getFarmElementImagePath(farmElement:String, color:String = null):String
		{
			var result:String = null;

			if (farmElement == FarmElement.STABLE && color != null)
			{
				result = ImageHandler.FARM_ELEMENTS_ROOT_PATH + AbstractEnum.toTitleCase(color) + "Stable.png";
			}
			else if (farmElement != null)
			{
				result = ImageHandler.FARM_ELEMENTS_ROOT_PATH + AbstractEnum.composedWordToTitleCase(farmElement) + ".png";
			}
			
			return result;
		}
	}
}